﻿<?php
	require_once('template/template1.phtml');
?>	
<script>
	function onXoaSp(id, ten_sp)
	{
		if (confirm('Bạn muốn xóa sp: '+ ten_sp ))
		{
			window.location.href = '<?php echo $config_basedir. "/WKSCP/sp_CMS.php?action=DEL&id="; ?>' + id;
		}
		return false;
	} 
</script>
	<h2>Danh sách sản phẩm
		<span class="floatright"><a style='color:yellow;' href ='sp_CMS.php?action=ADD'> Thêm sản phẩm </a></span>
	</h2>
    <div id="productList">
        <table cellspacing="0" cellpadding="0" border="0" width="100%" class="grid">
            <caption>Sản phẩm</caption>
            <thead>
                <tr>
                    <th style="width: 200px">Hình </th>
                    <th style="width: auto">Tên sản phẩm</th>
                    <th style="width: 50px; text-align:center">Sửa</th>
					<th style="width: 70px; text-align:center">Xóa</th>
                </tr>
            </thead>
            <tbody>
<?php			
		foreach($sp as $value){
		echo	"<tr>";
		echo		"<td>";
		echo			"<img alt='{$value['ten_sp']}'width='80px' src='{$value['img_url']}'>";
		echo		"</td>";
		echo		"<td>";
		echo			$value['ten_sp'];		
		echo		"</td>";
		echo		"<td align='center'><a href='sp_CMS.php?action=EDIT&id={$value['id']}'>Sửa </td>";
		echo		"<td align='center'>
						<a onclick=\"javascript: return onXoaSp({$value['id']}, '{$value['ten_sp']}')\" href=#>Xóa</a>";
		echo 		"</td>";
		echo	"</tr>";
		}
?>
            </tbody>
        </table>
		<?php	doPages('page', $rowPerPage, null, 'action=LIST', $numSp); ?>

	</div>
<?php	
	require_once('template/template2.phtml');
?>